package zheezes.eisp.compute.model;

import org.apache.log4j.Logger;

import zheezes.eisp.data.dao.DataAccessor;
import zheezes.eisp.data.orm.CalcTask;
import zheezes.util.DateFormatUtil;


public abstract class CalcTaskHandler implements Runnable {
	private final static Logger logger = Logger.getLogger(CalcTaskHandler.class);

	protected CalcTask task;
	protected DataAccessor dataAccessor;
	protected CondChecker condChecker;
	
	protected boolean terminated = false;
	
	static {
		logger.debug("Loading");
	}

	public void setDataAccessor(DataAccessor dataAccessor) {
		if (this.dataAccessor == null) {
			this.dataAccessor = dataAccessor;
		}
	}

	public CalcTask getTask() {
		return task;
	}

	public void setTask(CalcTask task) {
		this.task = task;
	}

	public void setCondChecker(CondChecker condChecker) {
		this.condChecker = condChecker;
	}
	
	public void terminate() {
		terminated = true;
	}

	public void desc() {
		logger.debug(String.format("task date = %s", DateFormatUtil.getDateFmt().format(task.getDate())));
	}
}